home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / Cineguide_nl.ifs < prev    next >
Text File  |  2005-03-13  |  6KB  |  193 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=Epsilon, Antoine Potten
  8. Title=Cineguide (Cinebel)
  9. Description=Cineguide (Cinebel) - Dutch (BE) import
  10. Site=http://www.cineguide.be
  11. Language=NL
  12. Version=
  13. Requires=3.5.0
  14. Comments=
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19. SummaryToComments=0|0|0=Puts summary in the description field|1=Puts summary in the comments field
  20.  
  21. ***************************************************)
  22.  
  23. program CINEGUIDE_NL;
  24. var
  25.   MovieName: string;
  26.  
  27. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  28. var                   
  29.   i: Integer;
  30. begin
  31.   result := -1;
  32.   if StartAt < 0 then
  33.     StartAt := 0;
  34.   for i := StartAt to List.Count-1 do
  35.     if Pos(Pattern, List.GetString(i)) <> 0 then
  36.     begin
  37.       result := i;
  38.       Break;
  39.     end;
  40. end;
  41.  
  42. procedure AnalyzePage(Address: string);
  43. var
  44.   PageText: string;
  45.   Block: string;
  46.   ResultBlock: Integer;
  47.   BeginPos, EndPos: Integer;
  48.   ValueTitle, ValueAddress: string;
  49. begin
  50.   PageText := GetPage(Address);
  51.   if pos('<a href=/fr/film.asp', PageText) > 0 then
  52.   begin
  53.     SetField(fieldURL, Address);
  54.     AnalyzeMoviePage(PageText)
  55.   end
  56.   else
  57.   begin
  58.     PickTreeClear;
  59.     ResultBlock := Pos('<td class="cadre" height="16">', PageText);
  60.     while ResultBlock > 0 do
  61.     begin
  62.       Delete(PageText, 1, ResultBlock + 35);
  63.       EndPos := Pos('</td>', PageText);
  64.       PickTreeAdd(StringReplace(Copy(PageText, 1, EndPos - 1), #13#10 + '                   ', ''), '');
  65.       BeginPos := EndPos;
  66.       EndPos := Pos('<td height="10"> </td>', PageText);
  67.       Block := Copy(PageText, BeginPos, EndPos - BeginPos);
  68.       Delete(PageText, 1, EndPos);
  69.       BeginPos := Pos('<a href="/nl/film.asp', Block);
  70.       while BeginPos > 0 do
  71.       begin
  72.         Delete(Block, 1, BeginPos - 1);
  73.         EndPos := Pos('</a>', Block);
  74.         ValueTitle := Copy(Block, 1, EndPos - 1);
  75.         HTMLRemoveTags(ValueTitle);
  76.         BeginPos := Pos('"', Block);
  77.         EndPos := Pos('" class', Block);
  78.         ValueAddress := 'http://www.cinebel.be' + Copy(Block, BeginPos + 1, EndPos - BeginPos - 1);
  79.         PickTreeAdd(ValueTitle, ValueAddress);
  80.         EndPos := Pos('</td>', Block);
  81.         Delete(Block, 1, EndPos);
  82.         BeginPos := Pos('<a href="/nl/film.asp', Block);
  83.       end;
  84.       ResultBlock := Pos('<td class="cadre" height="16">', PageText);
  85.     end;
  86.     if PickTreeExec(Address) then
  87.       AnalyzePage(Address);
  88.   end;
  89. end;
  90.  
  91. procedure AnalyzeMoviePage(PageText: string);
  92. var
  93.   Line, Value: string;
  94.   IntValue: Integer;
  95.   BeginPos, EndPos: Integer;
  96. begin
  97.   BeginPos := Pos('<table border="0" width="95%" cellpadding="0" cellspacing="0">', PageText);
  98.   Delete(PageText, 1, BeginPos);
  99.  
  100.   // Original Title
  101.   BeginPos := Pos('<b class="cadre">', PageText);
  102.   Delete(PageText, 1, BeginPos + 16);
  103.   EndPos := Pos ('</b>', PageText);
  104.   Value := Copy(PageText, 1, EndPos - 1);
  105.   SetField(fieldOriginalTitle, Value);
  106.  
  107.   // Country & Year
  108.   BeginPos := Pos(' - ', PageText) + 3;
  109.   EndPos := Pos('</td>', PageText);
  110.   Line := Copy(PageText, BeginPos, EndPos - BeginPos);
  111.   EndPos := Pos(' - ', Line);
  112.   SetField(fieldCountry, Copy(Line, 1, EndPos - 1));
  113.   Delete(Line, 1, EndPos + 2);
  114.   EndPos := Pos(#13#10, Line);
  115.   SetField(fieldYear, Copy(Line, 1, EndPos - 1));
  116.  
  117.   // Description
  118.   BeginPos := Pos('<hr noshade width="100%" size="1" color="#000000">', PageText);
  119.   Delete(PageText, 1, BeginPos);
  120.   EndPos := Pos('<hr noshade width="100%" size="1" color="#000000">', PageText);
  121.   Line := Copy(PageText, 1, EndPos - 1);
  122.   Delete(PageText, 1, EndPos);
  123.   BeginPos := Pos('>', Line);
  124.   Delete(Line, 1, BeginPos);
  125.   Line := StringReplace(Trim(StringReplace(Line, #13#10, '')), '<br>', #13#10);
  126.   if GetOption('SummaryToComments') = 1 then
  127.     SetField(fieldComments, Line)
  128.   else
  129.     SetField(fieldDescription, Line);
  130.   
  131.   // Director
  132.   BeginPos := Pos('<b>Regisseur', PageText);
  133.   Delete(PageText, 1, BeginPos);
  134.   BeginPos := Pos('</b> ', PageText) + 5;
  135.   EndPos := Pos('</td>', PageText);
  136.   Value := Copy(PageText, BeginPos, EndPos - BeginPos);
  137.   HTMLRemoveTags(Value);
  138.   SetField(fieldDirector, Value);
  139.   
  140.   // Actors
  141.   BeginPos := Pos('<b>Acteurs', PageText);
  142.   Delete(PageText, 1, BeginPos);
  143.   BeginPos := Pos(' </b>', PageText) + 5;
  144.   EndPos := Pos('</td>', PageText);
  145.   Value := Copy(PageText, BeginPos, EndPos - BeginPos);
  146.   Value := StringReplace(Value, '                        ', '');
  147.   Value := StringReplace(Value, #13#10, '');
  148.   HTMLRemoveTags(Value);
  149.   SetField(fieldActors, Trim(Value));
  150.   
  151.   // Category
  152.   BeginPos := Pos('<b>Genre', PageText);
  153.   Delete(PageText, 1, BeginPos);
  154.   BeginPos := Pos('</b> ', PageText) + 5;
  155.   EndPos := Pos('</td>', PageText);
  156.   Value := Copy(PageText, BeginPos, EndPos - BeginPos);
  157.   EndPos := Pos(#13#10, Value);
  158.   SetField(fieldCategory, Copy(Value, 1, EndPos - 1));
  159.   
  160.   // Length
  161.   BeginPos := Pos('<b>Duur', PageText);
  162.   Delete(PageText, 1, BeginPos);
  163.   BeginPos := Pos(' </b>', PageText) + 5;
  164.   EndPos := Pos(' </td>', PageText);
  165.   Value := Copy(PageText, BeginPos, EndPos - BeginPos);
  166.   EndPos := Pos('.', Value);
  167.   IntValue := StrToInt(Copy(Value, 1, EndPos - 1), 0) * 60;
  168.   IntValue := IntValue + StrToInt(Copy(Value, EndPos + 1, Length(Value)), 0);
  169.   SetField(fieldLength, IntToStr(IntValue));
  170.  
  171.  
  172.  
  173.   //DisplayResults;
  174. end;
  175.  
  176. begin
  177.   if CheckVersion(3,5,0) then
  178.   begin
  179.     MovieName := GetField(fieldOriginalTitle);
  180.     if MovieName = '' then
  181.       MovieName := GetField(fieldTranslatedTitle);
  182.     if Input('Cineguide (Cinebel) Import', 'Enter the title (or the URL) of the movie:', MovieName) then
  183.     begin
  184.       if Pos('cinebel.be', MovieName) > 0 then
  185.         AnalyzePage(MovieName)
  186.       else
  187.         AnalyzePage('http://www.cinebel.be/nl/srch.asp?mot='+UrlEncode(MovieName));
  188.     end;
  189.   end else
  190.   ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  191. end.
  192.  
  193.